package com.ddtech.framework.notice.model;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import com.ddtech.framework.system.model.SysUser;
import com.ddtech.models.AbstractModel;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.UpdateTimestamp;

import javax.persistence.*;
import java.util.Date;

/**
 * 系统公告
* @author bin_pu
* @date 2019-11-27
*/
@Entity
@Data
@Table(name="SYS_NOTICE")
public class SysNotice extends AbstractModel{


    // 公告内容
    @Column(name = "CONTENT")
    private String content;

    // 创建时间
    @CreationTimestamp
    @Column(name = "CREATETIME")
    private Date createtime;

    // 公告名称
    @Column(name = "NAME")
    private String name;

    // 状态标识
    @Column(name = "STATUS")
    private Integer status;

    // 公告类型
    @Column(name = "TYPE")
    //private Integer type;
    private String type;

    // 更新时间
    @UpdateTimestamp
    @Column(name = "UPDATETIME")
    private Date updatetime;

    // 创建人
    @ManyToOne
    @JoinColumn(name = "OPERATOR")
    @JsonIgnore
    private SysUser operator;


    public void copy(SysNotice source){
        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
    }
}
